<!--
 * @Author: canlong.shen
 * @Date: 2021-11-02 10:21:43
 * @LastEditors: your name
 * @LastEditTime: 2021-11-02 22:25:13
 * @Description: file content
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>组件</title></title>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script src="https://unpkg.com/vue@next"></script>
  </head>
  <body>
    <div id="root"></div>
    <script>
      const app =   Vue.createApp({
        data() {
          return {
              posts:[
        { id: 1, title: 'My journey with Vue' },
        { id: 2, title: 'Blogging with Vue' },
        { id: 3, title: 'Why Vue is so fun' }
              ],
              postFontSize: 1
          }
        },
        methods: {
        }, 
        template: `
          <div>
            <div id="blog-posts-demo" :style="{ fontSize: postFontSize + 'em' }">
              <table>
              <blog-post
              @enlarge-text="postFontSize += 0.1"
                v-for="post in posts"
                :key="post.id"
                :title="post.title"
              ></blog-post>
              </table>
            </div>
         </div>`,
      }) 
      
  

      

       app.component("blog-post",{
          emits: ['enlargeText'],
            props:['title'],
            template: `<h4>{{ title }}</h4>
            <button  @click="$emit('enlargeText')">
        Enlarge text
      </button>
            `

      })

      const vm  =  app.mount("#root")

     
    </script>
  </body>
</html>
